package com.seal.commons.validator.jsr303;

import com.seal.commons.utils.IdcardUtils;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import org.apache.commons.lang3.StringUtils;

public class IdCardNumValidator implements ConstraintValidator<IdCardNum, String> {

	@Override
	public void initialize(IdCardNum value) {
	}

	@Override
	public boolean isValid(String value, ConstraintValidatorContext context) {
	    
	    if(StringUtils.isBlank(value)){
	        return true;
	    }
	    
        return IdcardUtils.validateIdCard18(value);
	}
}
